﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TasksModel
{
    [System.Xml.Serialization.XmlRootAttribute(Namespace = "http://mp.tasks.com/2010/")]
    public class TaskFlag : NamedObject
    {
        #region Properties

        private string _description;

        public string Description
        {
            [System.Diagnostics.DebuggerStepThrough]
            get { return _description; }
            set
            {
                if (!object.ReferenceEquals(_description, value))
                {
                    _description = value;
                    NotifyPropertyChanged("Description");
                }
            }
        }

        private int _rGBColor;

        /// <summary>
        /// 0x00rrggbb
        /// </summary>
        public int RGBColor
        {
            [System.Diagnostics.DebuggerStepThrough]
            get { return _rGBColor; }
            set
            {
                if (_rGBColor != value)
                {
                    _rGBColor = value;
                    NotifyPropertyChanged("RGBColor");
                }
            }
        }

        [System.Xml.Serialization.XmlIgnore]
        public int ToR
        {
            [System.Diagnostics.DebuggerStepThrough]
            get { return (_rGBColor & 0xFF0000) >> 16; }
        }

        [System.Xml.Serialization.XmlIgnore]
        public int ToG
        {
            [System.Diagnostics.DebuggerStepThrough]
            get { return (_rGBColor & 0x00FF00) >> 8; }
        }

        [System.Xml.Serialization.XmlIgnore]
        public int ToB
        {
            [System.Diagnostics.DebuggerStepThrough]
            get { return _rGBColor & 0x0000FF; }
        }

        public string UriSchema
        {
            [System.Diagnostics.DebuggerStepThrough]
            get { return BaseSchema + "flag"; }
        }

        #endregion

        #region Constructors

        public TaskFlag(Guid id)
        {
            ID = id;
        }

        public TaskFlag()
            : this(Guid.NewGuid())
        {
        }

        /// <summary>
        /// Deep copy. Does not copy events.
        /// </summary>
        public TaskFlag(TaskFlag tf)
            : this(tf.ID)
        {
            _description = tf._description;
            Name = tf.Name;
            _rGBColor = tf._rGBColor;
            Timestamp = tf.Timestamp;
        }
        #endregion
    }
}